package com.szgr.baoyin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.szgr.baoyin.R;
import com.szgr.baoyin.model.Day;

import java.util.List;

/**
 * Created by yang on 15/10/18.
 */
public class CalendarGridAdapter extends BaseAdapter {
    private Context mContext;

    private List<Day> data;
    public CalendarGridAdapter(Context context,List<Day> data){
        mContext = context;
        this.data = data;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_calendar_grid_view,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();
        holder.tv_day.setText(data.get(position).getNum());
        return convertView;
    }

    class ViewHolder{
        TextView tv_day;

        public ViewHolder(View view){
            tv_day = (TextView) view.findViewById(R.id.calendar_day);
        }
    }
}
